<template>
  <div class="mainsu">
    <div class="main_spac1">
      <div class="main_white padding10 paddingBottom20">
        <div class="mainor_form">
          <el-form
            :inline="true"
            :model="form"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="70px"
          >
            <el-form-item label="关键字" prop="keyword">
              <el-input
                v-model.trim="form.keyword"
                placeholder="用户名称/手机号码"
                clearable
                class="wid220"
              ></el-input>
            </el-form-item>

            <el-form-item>
              <el-button
                class="reset marginLeft10"
                type="primary"
                @click="$refs['userListFrom'].resetFields()"
                >重置</el-button
              >
              <el-button
                type="primary"
                @click="getArticleList"
                :loading="listLoading"
                >搜索</el-button
              >
            </el-form-item>
          </el-form>
        </div>
        <div class="main_table marginTop10" style="min-height: 550px">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="list.data"
            element-loading-text="加载中"
            fit
            border
            highlight-current-row
          >
            <el-table-column label="序号">
              <template slot-scope="scope">{{
                (current.page - 1) * current.per_page + scope.$index + 1
              }}</template>
            </el-table-column>
            <el-table-column
              label="用户名称"
              prop="nickname"
              class-name="main_hei"
            >
              <template slot-scope="scope">{{ scope.row.nickname }}</template>
            </el-table-column>
            <el-table-column
              label="手机号"
              prop="mobile"
              class-name="main_hei"
            />
            <el-table-column
              label="创建时间"
              prop="created_at"
              class-name="main_hei"
            >
              <template slot-scope="scope">
                {{ parseTime(scope.row.created_at, "{y}-{m}-{d}") }}
              </template>
            </el-table-column>
            <el-table-column
              label="管理操作"
              align="center"
              fixed="right"
              width="140"
              class-name="main_hei"
            >
              <template slot-scope="scope">
                <el-link type="warning" @click="knotClick(scope.row.id)"
                  >恢复</el-link
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="main_page boxdq">
          <div></div>
          <!-- 分页 -->
          <div class="main_page_r">
            <el-pagination
              :current-page="current.page"
              :page-sizes="[20, 30, 50, 100]"
              :page-size="limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalCount"
              background
              @size-change="changeLimit"
              @current-change="changePage"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  recycle_member,
  recycle_recycleMember,
} from "@/api/global/globalRecycle";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { parseTime } from "@/utils/index";

export default {
  components: {},
  data() {
    return {
      parseTime,
      // 分页
      current: {
        page: 1,
        per_page: 20,
      },
      limit: 20,
      totalCount: 1,
      // 列表数据
      list: {
        list: [],
      },
      listLoading: false,
      // 搜索
      form: {
        keyword: "",
      },
    };
  },
  created() {
    // 列表
    // this.recycle_member();
  },
  methods: {
    // 恢复
    knotClick(id) {
      let data = Object.assign(
        apiUrl().name,
        { id: id }
      );
      recycle_recycleMember(data).then((res) => {
        if (res.errcode == 0) {
          this.$message({
            message: "恢复成功",
            type: "success",
          });
          this.recycle_member();
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 搜索
    getArticleList() {
      this.current.page = 1;
      this.recycle_member();
    },
    // 分页
    changeLimit(pageSize) {
      this.current.per_page = pageSize;
      this.recycle_member();
    },
    changePage(page) {
      this.current.page = page;
      this.recycle_member();
    },
    // 列表
    recycle_member() {
      this.listLoading = true;
      let data = Object.assign(
        apiUrl().name,
        this.list_form(),
        this.current
      );
      recycle_member(data).then((res) => {
        console.log(res);
        this.listLoading = false;
        if (res.errcode == 0) {
          this.list = res.data.list;
          this.totalCount = res.data.list.total;
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    list_form() {
      let form = JSON.parse(JSON.stringify(this.form));

      return form;
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.mainsu {
  .mainor_form form {
    width: calc(100% - 160px);
  }
}
</style>
